const http = require('http')
const fs = require('fs')
const srever = http.createServer((req, res) => {
    res.setHeader("Content-Type", "text/html;charset=utf-8");
    let url = './tast'
    let arr = fs.readdirSync(url)
    console.log(arr);
    let str = "<table> <tr><th>文件名</th><th>操作</th></tr>"
    arr.forEach(item => {
        let stat = fs.statSync(url + '/' + item)
        if (stat.isDirectory()) {
            str += `<tr><td><a href="#">${item}</a></td><td>删除</td></tr>`
        } else {
            str += `<tr><td>${item}</td><td>删除</td></tr>`
        }


    })
    str += "</table>";



    res.write(str)

    res.end()
})
srever.listen(9999)